/**
 * 
 */
package org.dse.analysis;

/**
 * This class just overwrites the compareTo method. Because the segmenter will
 * segment the text as a max-segmenter when querying, the logic of comparing on
 * the positions changes.
 * 
 * @author zhangchen
 * 
 */
public class MTokenDelegate extends TokenDelegate {

	/**
	 * The constructor.
	 * 
	 * @param offset
	 *            the read offset
	 * @param begin
	 *            the begin index from the offset
	 * @param end
	 *            the end index from the offset
	 */
	MTokenDelegate(int offset, int begin, int end) {
		super(offset, begin, end);
	}

	/**
	 * compareTo.
	 * 
	 * @param o
	 *            another object to be compared
	 * @return an integer representing the compare result
	 */
	public int compareTo(Object o) {
		MTokenDelegate mtd = (MTokenDelegate) o;
		if (getBegin() < mtd.getBegin())
			return -1;
		if (getBegin() == mtd.getBegin())
			return 0;
		return getEnd() > mtd.getEnd() ? 1 : 0;
	}
}